/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kohan.battleship;

/**
 *
 * @author STano
 */
public class Pc extends Player {
    private String level;
    
    public Pc (String color, String level) {
        super("PC", color);
        this.level = level;
    }

    @Override
    public boolean addShip(int x, int y) {
        return true;
    }

    @Override
    public int[] setCoordinates() {
        int[] coor = new int[2];
        
        coor[0] = (int)(9.0 * Math.random());
        coor[1] = (int)(9.0 * Math.random());
        
        return coor;
    }

    @Override
    public boolean hitShip(Board board) {
        int[] coor = setCoordinates();
     
        while(board.getBoard()[coor[0]][coor[1]].equals("M") ||
                board.getBoard()[coor[0]][coor[1]].equals("X")) {
            coor = setCoordinates();
        }
        if(board.getBoard()[coor[0]][coor[1]].equals("-")) {
            board.setFieldBoard("X", coor[0], coor[1]);
            System.out.println("-----HIT-----");
            return true;
        }
        board.setFieldBoard("M", coor[0], coor[1]);
        System.out.println("-----MISS-----");
        return false;
    }   
}
